package com.yun.zf.search.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yun.zf.common.admin.model.house.HouseListMo;
import com.yun.zf.common.app.domain.ZfHouseBasic;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 房源表 Mapper 接口
 * </p>
 *
 * @author cj
 * @since 2021-01-29
 */
@Mapper
public interface HouseMapper extends BaseMapper<ZfHouseBasic> {
    @Select("<script>" +
            " SELECT hb.id, hb.region_name, hb.street_name ,hb.community,hb.record_name,hb.modified_time,hb.city_code,hb.province_code , \n" +
            " hd.bedrooms,hd.living_room,hd.toilet,hd.area,hd.hoped_price ,hd.floor_tag,hd.total_floor,hd.direction,hd.price_unit,hd.title,hd.average_price,i.recommend_reason,i.is_recommend,i.tags\n" +
            " from zf_house_basic hb  LEFT JOIN  zf_house_detail hd  on  hb.id=hd.basic_id LEFT JOIN zf_house_info i on hb.id= i.basic_id   WHERE  hb.id in " +
            "<foreach item='item' index='index' collection='ids' open='(' separator=',' close=')' > " +
            "  #{item} " +
            "  </foreach>" +
            "and  hb.city_code=#{cityCode} and hb.province_code=#{provCode}  " +
            "</script>")
    public List<HouseListMo> getHouseList(Long provCode, Long cityCode, List<Long> ids);

}
